﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TechMadeira.Workflows;

namespace TechMadeira.App
{
    public partial class WorkflowTester : Form
    {
        public WorkflowTester()
        {
            InitializeComponent();

            OrderWorkflow.Instance.Current = OrderWorkflow.Instance.Ordered;
            Update();
        }

        public IOrderState State
        {
            get { return OrderWorkflow.Instance.Current; }
            set { OrderWorkflow.Instance.Current = value;  }
        }

        private void Update()
        {
            mStateTextBox1.Text = OrderWorkflow.Instance.Current.Name;
        }

        private void OnPrepare( object sender, EventArgs e )
        {
            OrderWorkflow.Instance.Current.Prepare();
            Update();
        }
        private void OnWait( object sender, EventArgs e )
        {
            OrderWorkflow.Instance.Current.Wait();
            Update();
        }
        private void OnDispatch( object sender, EventArgs e )
        {
            OrderWorkflow.Instance.Current.Dispatch();
            Update();
        }
        private void OnDeliver( object sender, EventArgs e )
        {
            OrderWorkflow.Instance.Current.Deliver();
            Update();
        }
        private void OnAccept( object sender, EventArgs e )
        {
            OrderWorkflow.Instance.Current.Accept();
            Update();
        }
        private void OnReturn( object sender, EventArgs e )
        {
            OrderWorkflow.Instance.Current.Return();
            Update();
        }
        private void OnRefund( object sender, EventArgs e )
        {
            OrderWorkflow.Instance.Current.Refund();
            Update();
        }
    }
}
